<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<script type="text/javascript" src="${staticPath}/static/ckeditor4.10/ckeditor.js"></script>
<style>
    p img {
        width: auto;
        height: auto;
        max-width: 100%;
    }
</style>
<script type="text/javascript">
    var todoDataGrid;
    var dialog;
    $(function() {
        todoDataGrid = $('#todoDataGrid').datagrid({
            url : '${path}/todo/dataGrid?userId=<shiro:principal property = "id"/>&status=0',
            striped : true,
            rownumbers : true,
            pagination : true,
            singleSelect : true,
            idField : 'id',
            sortName : 'id',
            sortOrder : 'asc',
            pageSize : 20,
            pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ],
            columns : [ [
                {
                    width : '300',
                    title : '标题',
                    field : 'title'
                },

                {
                    width : '100',
                    title : '类型',
                    field : 'typeName'
                },
                {
                    width : '120',
                    title : '创建时间',
                    field : 'createTime',
                    formatter:function (value,row,index) {
                        return datetime2Str(value);
                    }
                }
            ]],
            frozenColumns : [ [{
                field : 'action',
                title : '操作',
                width : 100,
                formatter : function(value, row, index) {
                    var str = '';
                        str += $.formatString('<a href="javascript:void(0)" class="todo-easyui-linkbutton-edit" data-options="plain:true,iconCls:\'fi-pencil icon-blue\'" onclick="edittodoFun(\'{0}\');" >办理</a>', row.operatorURL);
                    return str;
                }
            } ] ],
            onLoadSuccess:function(data){
                $('.todo-easyui-linkbutton-edit').linkbutton({text:'办理'});
            },
            toolbar : '#todoToolbar'
        });
    });


    function refreshTodo() {
        todoDataGrid.datagrid('reload');
    }
    function edittodoFun(url) {
      dialog=$('<div>').dialog({
            title : '办理',
            width : '80%',
            height : '80%',
              onClose : function() {
                  $(this).dialog('destroy');
              },
            href : '${path}'+url,
            buttons : [ {
                text : '确定',
                handler : function() {
                    updateTodo();
                }
            } ]
        });
    }
    function searchtodoFun() {
        todoDataGrid.datagrid('load', $.serializeObject($('#searchtodoForm')));
    }
    function cleantodoFun() {
        $('#searchtodoForm input').val('');
        todoDataGrid.datagrid('load', {});
    }

</script>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:true">
        <table id="todoDataGrid" data-options="fit:true,border:false"></table>
    </div>
</div>
<div id="todoToolbar" style="display: none;">
    <form id="searchtodoForm">
        <table>
            <tr>
                <td>标题</td>
                <td>
                    <input name="title"   type="text" placeholder="请输入标题" class="easyui-text  span2" >
                </td>
                <td>日期</td>
                <td>
                <td>
                    <input type="text" name="createTimeStart" class="easyui-text" onclick="WdatePicker()">~
                    <input type="text" name="createTimeEnd" class="easyui-text" onclick="WdatePicker()">
                </td>
                <td>
                    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fi-magnifying-glass',plain:true" onclick="searchtodoFun();">查询</a>
                    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fi-x-circle',plain:true" onclick="cleantodoFun();">清空</a>
                </td></tr>

        </table>
    </form>
</div>
